package com.javasm.controller.goodsController;

import com.javasm.common.http.AxiosResult;
import com.javasm.common.page.PageResult;
import com.javasm.controller.base.BaseController;
import com.javasm.domin.criteria.goodsCriteria.GdProductCriteria;
import com.javasm.domin.entity.goodsEntity.GdGoods;
import com.javasm.domin.entity.goodsEntity.GdProduct;
import com.javasm.domin.vo.goodsVo.GdProductVo;
import com.javasm.service.goodsService.GdProductService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：zzt
 * @Version：1.0
 * @Date：2021/11/22-15:37
 * @Since:jdk1.8
 * @Description:
 */
@RestController
@RequestMapping("/product")
@RequiredArgsConstructor
public class GdProductController extends BaseController {

    private final GdProductService gdProductService;

    /**
     * 查询所有
     *
     */
    @GetMapping("findList")
    public AxiosResult<PageResult<GdProductVo>> list(GdProductCriteria gdProductCriteria){
        PageResult<GdProductVo> gdProductVoPageResult = gdProductService.searchPage(gdProductCriteria);
        return AxiosResult.success(gdProductVoPageResult);
    }


    /**
     * 添加
     * @param
     * @return
     */
    @PostMapping("addProduct")
    public AxiosResult save(@RequestBody GdProduct gdProduct){

        boolean save = gdProductService.save(gdProduct);
        System.out.println(save);
        return AxiosResult.success(save);
    }

}
